package com.yangyang.msa.controller;

import com.yangyang.msa.entity.User;
import com.yangyang.msa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chenshunyang
 * @version 1.0
 * @date 2021/8/26 7:03 下午
 */
@RequestMapping("/users")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public List<User> findUserList() {
        System.out.println("findUserList");
        return userService.findUserList();
    }

    @GetMapping("")
    public User findUserById(@RequestParam Long id) {
        System.out.println("findUserById");
        return userService.findUserById(id);
    }

    @PostMapping("")
    public void saveUser(@RequestBody User user) {
        System.out.println("saveUser");
        userService.saveUser(user);
    }
}
